{% extends "layout.html" %}
{% block title %}VPN Site-to-Site 新增隧道{% endblock title%}

{% block trail %}
        <li><a href="/">Home</a></li>
        <li><a href="{{ url_for('sts.index') }}">VPN</a></li>
        <li class="current"><a href="{{ url_for('sts.index') }}">Site-to-Site</a></li>
{% endblock trail %}

{% block content %}
    {% include "sts/sidenav.html" %}

    <!-- start of sts vpn table -->
    <div class="large-10 columns">
      {% with messages = get_flashed_messages(with_categories=true) %}
      {% if messages %}
      {% for category, message in messages %}
      <div data-alert class="alert-box {{ category }}">
        {{ message }}
        <a href="#" class="close">&times;</a>
      </div>
      {% endfor %}
      {% endif %}
      {% endwith %}
      <div data-alert class="alert-box info">
        隧道ID：互相连接的隧道两端ID 需要保持一致。本端/对端子网：可以填写多个子网，用英文「,」分割。</li>
      </div>
      <form method="POST" action="{{ url_for('sts.add') }}">
        <div class="row">
          <div class="large-3 columns">
            {{ form.tunnel_name.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {% if form.tunnel_name.errors %}
            {{ form.tunnel_name(class="error", value=form.tunnel_name.value) }}
            <small class="error">{{ form.tunnel_name.errors[0] }}</small>
            {% else %}
            {{ form.tunnel_name(placeholder="home") }}
            {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.start_type.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {{ form.start_type }}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.ike_encryption_algorithm.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {{ form.ike_encryption_algorithm }}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.ike_integrity_algorithm.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {{ form.ike_integrity_algorithm }}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.ike_dh_algorithm.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {{ form.ike_dh_algorithm }}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.esp_encryption_algorithm.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {{ form.esp_encryption_algorithm }}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.esp_integrity_algorithm.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {{ form.esp_integrity_algorithm }}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.esp_dh_algorithm.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {{ form.esp_dh_algorithm }}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.local_subnet.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {% if form.local_subnet.errors %}
            {{ form.local_subnet(class="error") }}
            <small class="error">{{ form.local_subnet.errors[0] }}</small>
            {% else %}
            {{ form.local_subnet(placeholder="10.1.0.0/24, 10.1.1.0/24") }}
            {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.remote_ip.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {% if form.remote_ip.errors %}
            {{ form.remote_ip(class="error", value=form.remote_ip.value) }}
            <small class="error">{{ form.remote_ip.errors[0] }}</small>
            {% else %}
            {{ form.remote_ip(placeholder="100.69.0.119") }}
            {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.remote_subnet.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {% if form.remote_subnet.errors %}
            {{ form.remote_subnet(class="error") }}
            <small class="error">{{ form.remote_subnet.errors[0] }}</small>
            {% else %}
            {{ form.remote_subnet(placeholder="10.2.0.0/24, 10.2.1.0/24") }}
            {% endif %}
          </div>
        </div>
        <div class="row">
          <div class="large-3 columns">
            {{ form.psk.label(class="right inline") }}
          </div>
          <div class="large-5 columns end">
            {% if form.psk.errors %}
            {{ form.psk(class="error", value=form.psk.value) }}
            <small class="error">{{ form.psk.errors[0] }}</small>
            {% else %}
            {{ form.psk(placeholder="*DZ4J}[/*I7btVP6&lzXFyBlSV%D3@^]") }}
            {% endif %}
          </div>
        </div>

        <div class="row">
          <div class="large-3 columns large-offset-3">
            <button class="tiny success">保存</button>
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
          </div>
        </div>
      </form>
    </div>
    <!-- end of sts vpn table -->
{% endblock content %}
